home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / BTCONFIG.C < prev    next >
Text File  |  1991-09-15  |  38KB  |  1,156 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*               This module was written by Vince Perriello                 */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                  BinkleyTerm Configuration File Parser                   */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. char *ctl_slash_string (char *);
  51. static int Zone = 1;
  52.  
  53. void cfg_macro (char *);
  54. void cfg_dial_string (char *);
  55. void cfg_mdm_trans (char *);
  56. void cfg_domain (char *);
  57. void cfg_Janus (char *);
  58.  
  59. void parse_config (char *config_file)
  60. {
  61.    FILE *stream;
  62.    char temp[256];
  63.    char *c;
  64.    int i;
  65.    unsigned temp_num;
  66.    char *p;
  67.    ADDR temp_addr;                               /* Used to get address */
  68.  
  69.    (void) sprintf (temp, "%s%s", BINKpath, config_file);
  70.    if ((stream = share_fopen (temp, "rt", DENY_WRITE)) == NULL)     /* OK, let's open the file   */
  71.       return;                                    /* no file, no work to do    */
  72.  
  73.    while ((fgets (temp, 255, stream)) != NULL)   /* Now we parse the file ... */
  74.       {
  75.       c = temp;                                  /* Check out the first char  */
  76.       if ((*c == '%') || (*c == ';'))            /* See if it's a comment
  77.                                                   * line */
  78.          continue;
  79.  
  80.       i = (int) strlen (temp);                         /* how long this line is     */
  81.  
  82.       if (i < 3)
  83.          continue;                               /* If too short, ignore it   */
  84.  
  85.       c = &temp[--i];                            /* point at last character   */
  86.       if (*c == '\n')                            /* if it's a newline,        */
  87.          *c = '\0';                              /* strip it off              */
  88.  
  89.       if ((i = parse (temp, config_lines)) != 0)
  90.          {
  91.          c = &temp [(config_lines [i - 1]).p_length];
  92.          }
  93.  
  94.       switch (i)
  95.          {
  96.          case 1:                                /* "SameRing"      */
  97.             modemring = 1;
  98.             break;
  99.  
  100.          case 2:                                /* "NewNodeList"   */
  101.          case 129:                              /* "Version6"      */
  102.             newnodelist = 1;
  103.             break;
  104.  
  105.          case 3:                                /* "QuickNodeList" */
  106. #ifdef QUICK_LIST
  107.             nodefunc = QuickLookup;
  108.             newnodelist = 0;
  109. #endif
  110.             break;
  111.  
  112.          case 4:                                /* "Answerback"  */
  113.             answerback = ctl_string (c);
  114.             break;
  115.  
  116.          case 5:                                /* "Macro"         */
  117.             cfg_macro (c);
  118.             break;
  119.  
  120.          case 6:                                /* "Shell"        */
  121.             c = skip_blanks (c);
  122.             i = atoi (c);
  123.             if ((i <= 0) || (i > 9))
  124.                {
  125.                (void) printf ("%s %d %s\n", MSG_TXT(M_SHELL_NUMBER), i, MSG_TXT(M_OUT_OF_RANGE));
  126.                break;
  127.                }
  128.             c = skip_to_blank (c);
  129.             c = skip_blanks (c);
  130.             shells[i - 1] = calloc (1, strlen (c) + 1);
  131.             (void) strcpy (shells[i - 1], c);
  132.             (void) strupr (shells[i - 1]);
  133.             break;
  134.  
  135.          case 7:                                /* "Dial"         */
  136.             cfg_dial_string (c);
  137.             break;
  138.  
  139.          case 8:                                /* "Event"        */
  140.             c = skip_blanks (c);
  141.             (void) parse_event (c);
  142.             break;
  143.  
  144.          case 9:                                /* "Zone"         */
  145.             c = skip_blanks (c);
  146.             Zone = atoi (c);
  147.             if (!Zone)                          /* if we didn't find a zone  */
  148.                (void) printf (MSG_TXT(M_ILLEGAL_ZONE), &temp[4]);
  149.             break;
  150.  
  151.          case 10:                               /* "MaxReq"       */
  152.             (void) sscanf (c, "%d %d", &DEFAULT.rq_Limit, &DEFAULT.rq_Cum_Limit);
  153.             if (!DEFAULT.rq_Limit)              /* No requests??? */
  154.                (void) printf ("0 %s\n", MSG_TXT(M_REQUESTS_ALLOWED));
  155.             break;
  156.  
  157.          case 11:                               /* "LogLevel"     */
  158.             c = skip_blanks (c);
  159.             i = atoi (c);
  160.             if ((i <= 5) && (i > 0))
  161.                {
  162.                loglevel = i;
  163.                }
  164.             else
  165.                {
  166.                (void) printf (MSG_TXT(M_BAD_LOGLEVEL), &temp[8]);
  167.                }
  168.             break;
  169.  
  170.          case 12:                               /* "Baud"         */
  171.             temp_num = (unsigned int) atoi (c);
  172.             max_baud.rate_value = 0;
  173.             for (i = 0; btypes[i].rate_value; i++)
  174.                {
  175.                if (btypes[i].rate_value == temp_num)
  176.                   {
  177.                   max_baud.rate_mask = btypes[i].rate_mask;
  178.